package sonarqube

import (
	"strings"
)

/* UI
export enum ScannerEnv {
  ScannerEnvMode = 'SONAR_SCANNER_MODE',
  ScannerEnvLogin = "SONAR_LOGIN",
  ScannerEnvOpts = "SONAR_SCANNER_OPTS",
  ScannerEnvHostUrl = "SONAR_HOST_URL",
};
*/

const (
	EnvSonarqubeHostUrl = "SONAR_HOST_URL"
	EnvSonarScannerOpts = "SONAR_SCANNER_OPTS"
	EnvSonarLogin       = "SONAR_LOGIN"
	EnvAsync            = "SONAR_SCANNER_MODE"
	EnvTestTag          = "SONAR_SCANNER_TEST_TAG"
	EnvTestImageName    = "SONAR_SCANNER_TEST_IMAGE_NAME"
)

const (
	ExtractImageSonarqubeContainer = "sonar-scanner"
	ImageName                      = "sonar-scanner"
)

const (
	STRICT = "strict"
	NORMAL = "normal"
	IGNORE = "ignore"
)

const IMAGE = "registry.uniontech.com/utccp-operators/"

// 测试用
//const IMAGE = "registry.uniontech.com/utccp-operators-amd64/"

const (
	WorkMountDir = "/usr/src/"
)

// GetImageProjectName 获取镜像全项目路径名称
func GetImageProjectName(image string) string {
	// return image[:strings.LastIndexByte(image, '/')+1]
	return IMAGE
}

// GetImageTag 获取镜像标签
func GetImageTag(image string) string {
	return image[strings.LastIndexByte(image, ':'):]
}

// GetImageName 获取镜像全路径
func GetImageName(image string) string {
	return GetImageProjectName(image) + ImageName + GetImageTag(image)
}
